﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections; 

namespace YT.Modules
{
    public partial class frmGifImage : Form
    {
        private bool mblnExit = false;
        public frmGifImage()
        {
            InitializeComponent();
        }

        public void ShowGifImage()
        {
            ArrayList arrName = new ArrayList();
            arrName.Add(1);
            arrName.Add(2);
            arrName.Add(3);
            arrName.Add(4);
            arrName.Add(5);
            Random rad = new Random();
            int intRad = 0;
            while (!arrName.Contains(intRad))
            {
                intRad = rad.Next(1, 5);
            }
            SetImage(intRad);
        }


        private void SetImage(int intType)
        {
            //if (intType == 0) picGif.Image = Modules.Properties.Resources._182;
            if (intType == 1) picGif.Image = Modules.Properties.Resources.MOMO ;
            if (intType == 2) picGif.Image = Modules.Properties.Resources._041223zf_01;
            if (intType == 3) picGif.Image = Modules.Properties.Resources._041223zf_02;
            if (intType == 4) picGif.Image = Modules.Properties.Resources._41461_1;
            if (intType == 5) picGif.Image = Modules.Properties.Resources._41462_1;
            
            picGif.Enabled = true;
            timer1.Start(); 
        }

        private void frmGifImage_Load(object sender, EventArgs e)
        {
            ArrayList arrName = new ArrayList();
            arrName.Add(1);
            arrName.Add(2);
            arrName.Add(3);
            arrName.Add(4);
            arrName.Add(5);
            Random rad = new Random();
            int intRad = 0;
            while (!arrName.Contains(intRad))
            {
                intRad = rad.Next(1, 5);
            }
            SetImage(intRad);
            timer2.Start();            
        }

        private void picGif_Click(object sender, EventArgs e)
        {
            timer2.Start();             
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            mblnExit = true;
            timer2.Start();            
        }

        private void timer2_Tick(object sender, EventArgs e)
        {
            if (mblnExit == true)
            {
                if (this.Opacity <= 0.1)
                {
                    timer2.Stop();
                    this.Close();
                }
                this.Opacity -= 0.04;
            }
            else
            {
                if (this.Opacity >=1)
                {
                    timer2.Stop();                    
                }
                this.Opacity += 0.04;
            }
        }
    }
}
